


import React, { Component } from 'react';
import Colgroup from './colgroup';
import TableInfo from './tableInfo';
import TableFoot from './tableFoot';
import GridTable from './gridTable';
import PatientInfo from './patientInfo';
import SvgCenter from './svgCenter';
import PropTypes from 'prop-types'

import "./temperature.css"

class Temperature extends Component {
    constructor(props) {
        super(props);
        this.state = {
            sourceData: this.props.sourceData,
        };
    }

    componentWillReceiveProps(nextProps, nextState) {
        if (nextProps.sourceData !== nextState.sourceData) {

            this.setState({
                sourceData: nextProps.sourceData,
            })
        }
    }



    static propTypes = {
        sourceData: PropTypes.object,
    }


    static defaultProps = {
        sourceData: {},
    }


    render() {




        let { smallUrine = [], blood = [], height = [], weight = [], hospital, patientInfo, diagnosis, beginDate, inHosDays, dayOps, xl, mb, wd, eventDatas = [], hx, rl = [], cl = [], bigShit = [] } = this.state.sourceData

        let svgCenterData = {
            xl: xl,
            mb: mb,
            wd: wd,
            eventDatas: eventDatas
        }


        let footData = {
            hx: hx,
            rl: rl,
            cl: cl,
            bigShit: bigShit,
            smallUrine: smallUrine,
            height,
            weight,
            blood
        }





        return (
            <div className='temperatureContain'>

                <div className="fixed_div">
                    <PatientInfo hospital={hospital} patientList={patientInfo} diagnosis={diagnosis} />
                </div>

                <table className='tempCartHeader'>
                    <Colgroup />
                    <TableInfo beginDate={beginDate} dayList={inHosDays} dayOps={dayOps} />
                </table>

                <div className="tempSvgCenter">
                    <div className="tempSvgCenter1">
                        <SvgCenter curDate={beginDate} data={svgCenterData} />
                    </div>
                </div>

                <table className='tempCartCenter'>
                    <Colgroup />
                    <GridTable />

                </table>

                <table className='tempCartHeader'>
                    <Colgroup />
                    <TableFoot beginDate={beginDate} sourceData={footData} />

                </table>

            </div>
        );
    }
}

export default Temperature;